// 入口文件
import { runWithConcurrency } from "./concurrency.js";
import { TOPICS, MAX_CONCURRENCY, TIMEOUT_MS } from "./config.js";
import { streamExplain } from "./streamExplain.js";

async function main() {
  await runWithConcurrency(
    TOPICS,
    async (topic, idx) => {
      // 标记当前是第几个任务
      const label = `${idx + 1}/${TOPICS.length}`;

      // 该方法是执行单个任务
      try {
        await streamExplain(topic, label, TIMEOUT_MS);
      } catch (err) {
        console.error(`\n [${label}] ${topic} 失败：`, err?.message ?? err);
      }
    },
    MAX_CONCURRENCY
  );
}
main();
